class Avatar < Asset
	belongs_to :user
	
	has_attachment :content_type => :image, 
	         :storage => :file_system, :path_prefix => 'public/attachments/avatars',
	         :max_size => 1.megabytes,
	         :size => 0.kilobytes..1000.kilobytes,
	         :resize_to => '100x100!',
	         :processor => 'Rmagick',
	         :thumbnails => {:content => '50x50!'}
	         
	validates_as_attachment
	
	def before_create
		extension = self.filename.scan(/\.\w+$/)
		self.filename = self.filename.parameterize.gsub(/\-\w+$/,'').to_s+"#{extension}"
	end
end
